﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class PetTotemConfig extends Object
    {
        private var _targetDic:Dictionary;
        private var _equipDic:Dictionary;
        private var _itemDic:Dictionary;
        private static var _instance:PetTotemConfig;

        public function PetTotemConfig()
        {
            this.initTarget();
            this.initEquip();
            this.initItem();
            return;
        }// end function

        private function initTarget() : void
        {
            var _loc_2:Object = null;
            var _loc_3:TPetTotemTarget = null;
            this._targetDic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_pet_totem_target.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new TPetTotemTarget();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._targetDic[_loc_3.totemId + "_" + _loc_3.totemLevel] = _loc_3;
            }
            return;
        }// end function

        private function initEquip() : void
        {
            var _loc_2:Object = null;
            var _loc_3:TPetEquipConfig = null;
            this._equipDic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_pet_totem_equip.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new TPetEquipConfig();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._equipDic[_loc_3.equipId] = _loc_3;
            }
            return;
        }// end function

        private function initItem() : void
        {
            var _loc_2:Object = null;
            var _loc_3:TPetTotemItemConfig = null;
            this._itemDic = new Dictionary();
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_pet_totem_item_config.json");
            for each (_loc_2 in _loc_1)
            {
                
                _loc_3 = new TPetTotemItemConfig();
                ClassTypesUtil.copyValue(_loc_3, _loc_2);
                this._itemDic[_loc_3.code] = _loc_3;
            }
            return;
        }// end function

        public function getTargetItem(param1:int, param2:int) : TPetTotemTarget
        {
            return this._targetDic[param1 + "_" + param2] as TPetTotemTarget;
        }// end function

        public function getEquipItem(param1:int) : TPetEquipConfig
        {
            return this._equipDic[param1] as TPetEquipConfig;
        }// end function

        public function getItem(param1:int) : TPetTotemItemConfig
        {
            return this._itemDic[param1] as TPetTotemItemConfig;
        }// end function

        public static function get instance() : PetTotemConfig
        {
            if (!_instance)
            {
                _instance = new PetTotemConfig;
            }
            return _instance;
        }// end function

    }
}
